package com.nut.lmsc.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.nut.lmsc.common.BaseEntity;
import lombok.Data;

import java.util.List;

/**
 * 商品表
 */
@Data
@TableName("biz_goods")
public class Goods extends BaseEntity {

    private Integer id;

    //店铺ID
    private Integer shopId;

    //店铺名称
    private String shopName;

    //类目路径
    private String catPathId;

    //类目路径
    private String catPathName;

    //名称
    private String title;

    //封面图
    private String img;

    //卖点
    private String sellPoint;

    //计量单位
    private String unit;

    //价格 分
    private Integer price;

    //商品类型 1实物 2虚拟
    private Integer type;

    //代金券比例 百分之几  整数
    private Integer couponRatio;

    //代金券金额 分
    private Integer couponMoney;

    //销售模式 1零售 2批发
    private Integer sellMode;

    //排序 排序值越大越靠前
    private Integer sort;

    //状态 0初始状态 1已下架 2待审核 3审核不通过 4审核通过 5已上架
    private Integer status;

    //轮播图
    @TableField(exist = false)
    private String slider;

    //内容
    @TableField(exist = false)
    private String content;

    //移动端详情
    @TableField(exist = false)
    private String mobileInfo;

    //视频
    @TableField(exist = false)
    private String video;

    //商品规格列表
    @TableField(exist = false)
    private List<GoodsSpec> specList;

    //商品销售模式列表
    @TableField(exist = false)
    private List<GoodsSellMode> modeList;

    public GoodsDetail getGoodsDetail() {
        GoodsDetail goodsDetail = new GoodsDetail();
        goodsDetail.setId(id);
        goodsDetail.setSlider(this.slider);
        goodsDetail.setContent(this.content);
        goodsDetail.setMobileInfo(this.mobileInfo);
        goodsDetail.setVideo(this.video);
        return goodsDetail;
    }

    public boolean needUpdateDetail() {
        return this.slider != null ||
                this.content != null ||
                this.mobileInfo != null ||
                this.video != null;
    }

    public boolean needUpdate() {
        return this.catPathId != null ||
                this.catPathName != null ||
                this.title != null ||
                this.img != null ||
                this.sellPoint != null ||
                this.unit != null ||
                this.price != null ||
                this.couponRatio != null ||
                this.sellMode != null ||
                this.sort != null ||
                this.status != null;
    }
}
